﻿using System;
using System.Collections.Generic;
using System.Text;
using WeatherTest.Base;

namespace WeatherTest
{
    public class LoveIndexDisplay : IObserver, IDisplayElement
    {
        private float _temp, _humidity, _pressure, _sum;
        private int count;

        public void Display()
        {
            //throw new NotImplementedException();
            Console.WriteLine($"恋爱指数为：{_temp} * {_humidity} / {_pressure} = {_sum}");
        }


        public void Update(float temp, float humidity, float pressure)
        {
            //throw new NotImplementedException();
            _temp += temp;
            count++;
            _temp = _temp / count;
            _humidity = humidity;
            _pressure = pressure;
            _sum = (_temp * _humidity) / _pressure;
            Display();
            if (_sum > 10)
            {
                Console.WriteLine("恋爱指数大于10，今天适合谈恋爱");
            }
            else
            {
                Console.WriteLine("恋爱指数小于10，今天你依旧单身！");
            }

        }
    }
}
